<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
    <title>用户管理</title>
    <style>
        body {
            background: #f5f5f5;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            color: #1a1a1a;
            margin: 0;
            padding: 0;
        }
        .container {
            max-width: 900px;
            margin: 40px auto;
            background: #fff;
            border-radius: 12px;
            box-shadow: 0 4px 20px #0001;
            padding: 32px;
        }
        .section-title {
            font-size: 28px;
            font-weight: 600;
            color: #1a1a1a;
            margin-bottom: 8px;
        }
        .section-subtitle {
            color: #666;
            font-size: 16px;
            margin-bottom: 24px;
        }
        .users-table {
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
            overflow: hidden;
            border-collapse: separate;
            border-spacing: 0;
            width: 100%;
        }
        .users-table thead {
            background: #f8f8f8;
        }
        .users-table th {
            padding: 16px 12px;
            text-align: left;
            font-weight: 600;
            color: #1a1a1a;
            border-bottom: 2px solid #e5e5e5;
            font-size: 14px;
        }
        .users-table td {
            padding: 16px 12px;
            border-bottom: 1px solid #f0f0f0;
            color: #1a1a1a;
            font-size: 14px;
        }
        .users-table tbody tr {
            transition: all 0.3s ease;
        }
        .users-table tbody tr:hover {
            background: #f8f8f8;
            transform: scale(1.01);
        }
        .action-links {
            display: flex;
            gap: 12px;
            align-items: center;
            justify-content: flex-start;
        }
        .action-btn {
            padding: 6px 16px;
            border-radius: 6px;
            font-size: 14px;
            font-weight: 500;
            border: none;
            cursor: pointer;
            transition: all 0.2s;
            margin: 0 2px;
            display: inline-flex;
            align-items: center;
            gap: 4px;
            background: #f5f5f5;
            color: #222;
            text-decoration: none;
            box-shadow: 0 1px 4px #0001;
        }
        .action-btn:hover {
            background: #e0e0e0;
            color: #111;
            box-shadow: 0 2px 8px #0002;
            transform: translateY(-1px);
        }
        .action-btn.primary {
            background: #1a1a1a;
            color: #fff;
        }
        .action-btn.primary:hover {
            background: #333;
        }
        .action-btn.danger {
            background: #d32f2f;
            color: #fff;
        }
        .action-btn.danger:hover {
            background: #b71c1c;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="section-title">用户管理</div>
    <div class="section-subtitle">管理系统用户账号状态</div>
    <c:if test="${not empty msg}"><div style="color:green">${msg}</div></c:if>
    <c:if test="${not empty error}"><div style="color:red">${error}</div></c:if>
    <table class="users-table">
        <thead>
        <tr>
            <th>用户名</th>
            <th>邮箱</th>
            <th>角色</th>
            <th>状态</th>
            <th>注册时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach var="user" items="${userList}">
            <tr>
                <td>${user.username}</td>
                <td>${user.email}</td>
                <td>${user.role}</td>
                <td>${user.status}</td>
                <td><c:if test="${not empty user.createdAt}">${fn:substring(user.createdAt, 0, 19)}</c:if></td>
                <td style="text-align:left;">
                    <div class="action-links">
                        <form action="/user/toggle-status" method="post" style="display:inline; margin:0;">
                            <input type="hidden" name="userId" value="${user.id}" />
                            <input type="hidden" name="status" value="DISABLED" />
                            <button type="submit" class="action-btn danger" onclick="return confirm('确定禁用该用户？')">禁用</button>
                        </form>
                        <form action="/user/toggle-status" method="post" style="display:inline; margin:0;">
                            <input type="hidden" name="userId" value="${user.id}" />
                            <input type="hidden" name="status" value="ACTIVE" />
                            <button type="submit" class="action-btn primary" onclick="return confirm('确定启用该用户？')">启用</button>
                        </form>
                    </div>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
</body>
</html> 